/**   
 * @Title: HibUserDaoImpl.java   
 * @Package edu.adweb.ssh.dao   
 * @Description: TODO(用一句话描述该文件做什么)
 * Copyright: Copyright (c)  2011  
 * Company: Fudan   
 * @author FangYong   
 * @date 2011 2011-3-31 上午09:13:57   
 *@version 1.0   
 */    
package edu.adweb.ssh.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import edu.adweb.ssh.bean.User;

/**
 * @ClassName: HibUserDaoImpl   
 * @Description: TODO(这里用一句话描述这个类的作用)   
 * @author FangYong   
 * @date 2011-3-31 上午09:13:57   
 */
public class HibUserDaoImpl extends HibernateDaoSupport implements UserDao{

	/* (none Javadoc)
	 * <p>Title: delete</p>    
	 * <p>Description:  </p>    
	 * @param u    
	 * @see edu.adweb.ssh.dao.UserDao#delete(edu.adweb.ssh.bean.User)    
	 */
	@Override
	public void delete(User u) {
		this.getHibernateTemplate().delete(u);
		//return;
	}

	/* (none Javadoc)
	 * <p>Title: find</p>    
	 * <p>Description:  </p>    
	 * @param id
	 * @return    
	 * @see edu.adweb.ssh.dao.UserDao#find(java.lang.Integer)    
	 */
	@Override
	public User find(Integer id) {
		List ret = this.getHibernateTemplate().find("from User where id = " + id );
		if(ret != null && ret.size() != 1)
			return null;
		return (User)(ret.get(0));
	}

	/* (none Javadoc)
	 * <p>Title: find</p>    
	 * <p>Description:  </p>    
	 * @param name
	 * @return    
	 * @see edu.adweb.ssh.dao.UserDao#find(java.lang.String)    
	 */
	@Override
	public List<User> find(String name) {
		return this.getHibernateTemplate().find("from User where name = '" + name +"'");
	}

	/* (none Javadoc)
	 * <p>Title: save</p>    
	 * <p>Description:  </p>    
	 * @param u    
	 * @see edu.adweb.ssh.dao.UserDao#save(edu.adweb.ssh.bean.User)    
	 */
	@Override
	public void save(User u) {
		this.getHibernateTemplate().save(u);		
	}

}
